$(function() {
	if(getCookieValue("token")==""){
		window.location.href = 'l-userlogin.html'
	}
	
	
	heardLook(function(data) {
		$('.areaSign').html(template('areaSignTemplate', data))
	});
	
	$('.user-btn').on('tap',function(){
		var areaHtml = $('.user-area').val();
		console.log(areaHtml,789);
		personRevise({
			userSignsture:areaHtml,
			token:getCookieValue("token")
		},function(data){
			mui.toast('修改成功！');
		});
	});
});

//个人信息
var heardLook = function(callback) {
	$.ajax({
		type: "post",
		cache: false,
		traditional: true,
		dataType: "json",
		url: window.address + "/user/findBayUserUuid",
		xhrFields: {
			withCredentials: true
		},
		crossDomain: true,
		data: {
			"userUuid":CD.geturl().business
		},
		success: function(data) {
			console.log(data);
			callback && callback(data);
		}
	});
}

//修改
var personRevise = function(params, callback) {
	$.ajax({
		type: "get",
		url: window.address + "/user/userUpdate",
		xhrFields: {
			withCredentials: true
		},
		crossDomain: true,
		data: params,
		dataType: "json",
		success: function(data) {
			console.log(data, 11111)
			callback && callback(data);
		}
	});
};

//文字数量监听
function limitTextarea(self, nowleng) {
	$(self).on('input propertychange', function(event) {
		var _val = $(self).val();
		_val = _val < 140 ? _val : _val.substr(0, 140);
		$(self).val(_val);
		$(nowleng).text(_val.length)
	});
	$(self).blur(function() {
		$(self).off('input propertychange');
	});
}